package com.csc.banking.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.csc.banking.dao.SystemUserDAO;

@Controller
public class SystemUserController {
	@Autowired
	SystemUserDAO usDAO;
	
	@RequestMapping(value = "/login",method=RequestMethod.POST)
	public String doLoginCustomer(HttpServletRequest request, Model model) {
		// Read account info from request and save into Account object
		String userName = request.getParameter("userName");
		String password = request.getParameter("password");
		System.out.println(userName + " ," +password);
		if(usDAO.login(userName,password)){
			System.out.println(" login ok!!!");
			
			return ("home");
		}else{
			System.out.println(" login failed!!!");
			return ("login");
		}
		
	}
	
	@RequestMapping(value = "/login",method=RequestMethod.GET)
	public String LoginCustomer() {
		
			return "login";
		
		
	}
}
